<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计算器</title>
	</head>
	<body>
		<div>
			<form>
				<input id="num1" type="text" />&nbsp;&nbsp;
				<select id="symbol">
					<option value="+">+</option>
					<option value="-">-</option>
					<option value="*">*</option>
					<option value="/">/</option>
				</select>&nbsp;&nbsp;
				<input id="num2" type="text" />&nbsp;&nbsp;
				<button type="button" id="count" onclick="click();">计算</button>&nbsp;&nbsp;
				<span id="num3"></span>
			</form>
			
		</div>
	</body>
	
	<script type="text/javascript">
		function click(){
			var num1 = document.getElementById('num1').value;
			var num2 = document.getElementById('num2').value;
			var c = document.getElementById('symbol').value;
			var num3 = document.getElementById('num3').value;
			num1 = parseFloat(num1);
			num2 = parseFloat(num2);
			switch (c) {
				case "+":
					num3.innerHTML = num1 + num2;
				break;
				case "-":
					num3.innerHTML = num1 - num2;
				break;
				case "*":
					num3.innerHTML = num1 * num2;
				break;
				case "/":
					num3.innerHTML = num1 / num2;
				break;
			}
	</script>
</html>
